<!-- Note: Original code from https://www.sidorenko.io/post/2017/07/nice-tagcloud-with-hugo/ -->
<main class="main list" id="main">
    <div class="main-inner">
        <div class="content tag-cloud">
            {{ if .Site.Params.displayListTitle }}
                <h1 class="list-title">{{ .Title | default (.Type | title) }}</h1>
            {{ end }}
            {{ if ne (len $.Site.Taxonomies.tags) 0 }}
                {{ $fontUnit := $.Site.Params.fontUnit }}
                {{ $largestFontSize := $.Site.Params.largestFontSize }}
                {{ $smallestFontSize := $.Site.Params.smallestFontSize }}
                {{ $fontSpread := sub $largestFontSize $smallestFontSize }}
                {{ $max := add (len (index $.Site.Taxonomies.tags.ByCount 0).Pages) 1 }}
                {{ $min := len (index $.Site.Taxonomies.tags.ByCount.Reverse 0).Pages }}
                {{ $spread := sub $max $min }}
                {{ $fontStep := div $fontSpread $spread }}
                {{ range $name, $taxonomy := $.Site.Taxonomies.tags }}
                    {{ $currentTagCount := len $taxonomy.Pages }}
                    {{ $currentFontSize := (add $smallestFontSize (mul (sub $currentTagCount $min) $fontStep)) }}
                    {{ $count := len $taxonomy.Pages }}
                    {{ $weigth := div (sub (math.Log $count) (math.Log $min)) (sub (math.Log $max) (math.Log $min)) }}
                    {{ $currentFontSize := (add $smallestFontSize (mul (sub $largestFontSize $smallestFontSize) $weigth)) }}
                    {{ with $.Site.GetPage (printf "/tags/%s" $name) }}
                        <a href="{{ .RelPermalink }}" class="tag-cloud-item" style="font-size: {{ $currentFontSize }}{{ $fontUnit }}">{{ .LinkTitle | default .Data.Term | default $name }}</a>
                    {{ end }}
                {{ end }}
            {{ end }}
        </div>
    </div>
</main>